<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改投标管理')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: jasny-bootstrap-css" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
    <style>
		.file-preview {
		    padding: 0;
		    margin-bottom: 0;
		    border-radius: 0;
		    border: none;
		}
		
		.krajee-default.file-preview-frame {
		    margin-right: 20px;
		    padding: 0;
		    border: none;
		    box-shadow: none;
		}
		
		.krajee-default.file-preview-frame:not(.file-preview-error):hover {
		    border: none;
		    box-shadow: none;
		}
		
		.krajee-default .file-footer-caption {
			margin-bottom: 0;
		}
		
		.krajee-default.file-preview-frame .file-thumbnail-footer {
		    height: auto;
		}
		
		.krajee-default .file-caption-info {
			width: auto;
		}
		
		.kv-upload-progress .progress {
			margin-top: 0;
		}
		
		.krajee-default.file-preview-frame .kv-file-content,
		.krajee-default .file-size-info,
		.krajee-default .file-upload-indicator,
		.file-input .kv-file-upload,
		.file-input .kv-file-zoom {
			display: none;
		}
		
		.file-input .kv-file-remove {
			position: absolute;
			top: 3px;
			right: -15px;
			height: 14px;
			padding: 0;
			margin: 0;
			border: none;
			background: none;
		}
		
		.file-input .kv-file-remove:active, 
		.file-input .kv-file-remove:focus {
			background: none;
			outline: none;
			box-shadow: none;
		}
		
		.file-input .kv-file-remove .glyphicon-trash {
			color: red;
		}
	</style>
    <style type="text/css">
        table label.error{position: inherit;}select + label.error{z-index:1;right:40px;}
    </style>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-bidding-edit" th:object="${sjBidding}">
        	<h4 class="form-header h4">基本信息</h4>
            <input name="id" th:field="*{id}" type="hidden">
            <input type="hidden" id="zbFile" name="zbFile" th:field="*{zbFile}" />
            <input type="hidden" id="zbFilevo" name="zbFilevo" th:value="${zbFilevo}" />
            <input type="hidden" id="approvename" name="approvename" th:value="${approvename}" />
            <div class="form-group">    
                <label class="col-sm-2 control-label is-required">对接部门：</label>
                <div class="col-sm-4">
                    <input name="deptName" class="form-control" type="text" th:field="*{deptName}" autoComplete="off" readonly="readonly" required>
                    <input name="deptId" th:field="*{deptId}" type="hidden">
                </div>
                <label class="col-sm-2 control-label is-required">对接人：</label>
                <div class="col-sm-4">
                    <input name="owner" class="form-control" th:field="*{owner}" readonly="readonly" type="text" autoComplete="off" required>
                	<input name="ownerId" th:field="*{ownerId}" type="hidden">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label is-required">投标项目名称：</label>
                <div class="col-sm-4">
                    <input name="projectName" class="form-control" th:field="*{projectName}" type="text" required autoComplete="off">
                </div>
                <label class="col-sm-2 control-label is-required">开标地点：</label>
                <div class="col-sm-4">
                    <input name="kbdd" class="form-control" th:field="*{kbdd}" type="text" required autoComplete="off">
                </div>
            </div>
            <div class="form-group">    
				<label class="col-sm-2 control-label ">商机跟踪：</label>
                <div class="col-sm-4">
		            <select name="chanceId" th:field="*{chanceId}" class="form-control" >
		            	<option value="">空</option>
						<option th:each="chance:${chancelis}" th:value="${chance.id}" th:text="${chance.descs}"></option>
					</select>
                </div>
                <label class="col-sm-2 control-label is-required">开标日期：</label>
                <div class="col-sm-4">
                    <div class="input-group date">
                        <input name="kbAt" th:value="${#dates.format(sjBidding.kbAt, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label ">投标控制价：</label>
                <div class="col-sm-4">
                    <input name="tbkzj" th:field="*{tbkzj}" class="form-control" type="number"  autoComplete="off">
                </div>
                <label class="col-sm-2 control-label ">投标负责人：</label>
                <div class="col-sm-4">
                    <div class="input-group">
                    	<input name="tbfzr" th:field="*{tbfzr}" id="tbfzr" class="form-control" type="hidden">
                    	<input name="tbfzrId" th:field="*{tbfzrId}" id="tbfzrId" class="form-control" type="hidden">
                    	<input class="form-control" type="text" onclick="selecttbfzr()" th:value="*{tbfzr}" id="tbfzrStr" readonly="true" required>
						<span class="input-group-addon"><i class="fa fa-search"></i></span>
					</div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label is-required">保证金金额：</label>
                <div class="col-sm-4">
                    <input name="bzjje" th:field="*{bzjje}" class="form-control" type="number" required autoComplete="off">
                </div>
                <label class="col-sm-2 control-label is-required">投标状态：</label>
                <div class="col-sm-4">
                    <select name="status" th:field="*{status}" class="form-control" th:with="type=${@dict.getType('sj_bidding_status')}" required>
		                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
		            </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label is-required">投标类型：</label>
                <div class="col-sm-4">
                    <select name="tbType" th:field="*{tbType}" class="form-control" th:with="type=${@dict.getType('sj_tbType')}" required>
		                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
		            </select>
                </div>
                <label class="col-sm-2 control-label is-required">项目类型：</label>
                <div class="col-sm-4">
                    <select name="proType" th:field="*{proType}" class="form-control" th:with="type=${@dict.getType('sj_proType')}" required>
		                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
		            </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label">联合体方：</label>
                <div class="col-sm-4">
                    <input name="lhtf" th:field="*{lhtf}" class="form-control" type="text" autoComplete="off">
                </div>
                <label class="col-sm-2 control-label">投标管理费：</label>
                <div class="col-sm-4">
                    <input name="biddingJe" th:field="*{biddingJe}" class="form-control" type="text" autoComplete="off">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">备注：</label>
                <div class="col-sm-10">
                    <textarea name="memo" class="form-control" autoComplete="off">[[*{memo}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">招标文件：</label>
                <div class="col-sm-10" style="margin-top: 8px;" id="zbFilelink">
                </div>
            </div>
            <h4 class="form-header h4">表单项
            </h4>
            <div class="row">
                <div class="col-sm-12">
                    <div class="col-sm-12 select-table table-striped">
					    <table id="bootstrap-table"></table>
					</div>
                </div>
            </div>
        </form>
    </div>
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: jasny-bootstrap-js" />
    <th:block th:include="include :: bootstrap-suggest-js" />
    <th:block th:include="include :: bootstrap-typeahead-js" />
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <script th:src="@{/ruoyi/base64.min.js?v=20231208}"></script>
    <script th:src="@{/js/jquery.tmpl.js}"></script>
    <script th:inline="javascript">
        var prefix = ctx + "sj/bidding";
        $("#form-bidding-edit").validate({
            focusCleanup: true
        });
        
        $(function() {
			var zilwj = $("#zbFilevo").val();
        	
        	var n=zilwj.split(",");
        	for(var i=0;i<n.length;i++){
//         		var url = "http://lkgnews.cn:8012/onlinePreview?url="+encodeURIComponent(Base64.encode(n[i]));
        		var url = n[i];
        		$("#zbFilelink").append("<a href='"+url+"' target='_blank' >"+n[i]+"</a><br>");
        	}
        	
        	// 多图上传
	       $("#multipleFile").fileinput({
	           uploadUrl: "/common/uploads",
	           uploadAsync: false,
	           showClose: false,
	           showCancel: false,
	           dropZoneEnabled: false,
	           buttonLabelClass: ''
	       }).on('filebatchuploadsuccess', function (event, data, previewId, index) {
	       	var rsp = data.response;
	           log.info("reutrn fileNames：" + rsp.fileNames)
			   $("#zbFile").val(rsp.fileNames);
	       }).on('fileremoved', function (event, id, index) {
	           $("input[name='" + event.currentTarget.id + "']").val('')
	       })
	       
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.saveTab(prefix + "/edit", $('#form-bidding-edit').serialize());
            }
        }

        $("input[name='tbjzAt']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='kbAt']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='bxfkAt']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='yjtkAt']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $(document).ready(function () {
		       // 多图上传
		       $("#multipleFile").fileinput({
		           uploadUrl: "/common/uploads",
		           uploadAsync: false,
		           showClose: false,
		           showCancel: false,
		           dropZoneEnabled: false,
		           buttonLabelClass: ''
		       }).on('filebatchuploadsuccess', function (event, data, previewId, index) {
		       	var rsp = data.response;
//		       	   log.info("return urls：" + rsp.urls)
		           log.info("reutrn fileNames：" + rsp.fileNames)
//		           log.info("reutrn newFileNames：" + rsp.newFileNames)
//		           log.info("return originalFilenames：" + rsp.originalFilenames)
				   $("#zbFile").val(rsp.fileNames);
		       }).on('fileremoved', function (event, id, index) {
		           $("input[name='" + event.currentTarget.id + "']").val('')
		       })
		 });
        
        $(function() {
        	var data = [[${sjBidding.items}]];
	    	// 初始化数据, 可以由后台传过来
		    var options = {
		    	data: data,
                pagination: false,
		        showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
		        columns: [
		        {
		        	field: 'index',
		        	align: 'center',
		        	title: "序号",
		        	width: 50,
                    formatter: function (value, row, index) {
                    	var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                    	var columnId = $.common.sprintf("<input type='hidden' name='items[%s].xuh' value='%s'>", index, row.id);
                    	return columnIndex + $.table.serialNumber(index) + columnId;
                    }
                },
		        {
		            field: 'name',
		            align: 'center',
		            title: '姓名',
		            formatter: function(value, row, index) {
		            	var html = $.common.sprintf("<input class='form-control namecount' type='text' autoComplete='off' name='items[%s].name' value='%s'>", index, value);
		        		return html;
                    }
		        },
		        {
		            field: 'gwname',
		            align: 'center',
		            title: '岗位',
		            formatter: function(value, row, index) {
		        		var data = [{ index: index, type: value }];
		                return $("#itemGw").tmpl(data).html();
                 	}
		        },
		        {
		            field: 'je',
		            align: 'center',
		            title: '金额',
		            formatter: function(value, row, index) {
		            	var html = $.common.sprintf("<input class='form-control jecount' type='text' autoComplete='off' name='items[%s].je' value='%s'>", index, value);
		        		return html;
                    }
		        }]
		    };
		    $.table.init(options);
		});
        
        $.validator.addMethod("namecount", function(value, element) {
            return !this.optional(element);
        }, "姓名必填。");
        $.validator.addMethod("gwnamecount", function(value, element) {
            return !this.optional(element);
        }, "岗位必填。");
        $.validator.addMethod("jecount", function(value, element) {
            return !this.optional(element) && (value <= 10000000 && value >= 1);
        }, "金额长度区间1-10000000。");
        
        function addRow() {
        	var count = $("#" + table.options.id).bootstrapTable('getData').length;
        	var row = {
                index: $.table.serialNumber(count),
                name: "",
                je: "1",
                gwname: ""
            }
        	sub.addColumn(row);
        }
        
      //选择用户tbfzr
		function selecttbfzr() {
			var options = {
		       title: '选择用户',
		       url: "/sj/config/invokeUser",
		       width: '1000',
		       height: '670',
		       callBack: doSubmittbfzr
		    };
		    $.modal.openOptions(options);
		}
	 	
		function doSubmittbfzr(index, layero){
            var rows = layero.find("iframe")[0].contentWindow.getSelections();
            if (rows.length == 0) {
                $.modal.alertWarning("请选择一条记录！");
                return;
            }
            
            if (rows.length > 1) {
                $.modal.alertWarning("请勿选择多条记录！");
                return;
            }
            
            $("#tbfzrId").val(rows[0].userId);
            $("#tbfzr").val(rows[0].userName);
            $("#tbfzrStr").val(rows[0].userName);
            $.modal.closeAll();
        }
    </script>
</body>
</html>

<!-- 岗位 -->
<script id="itemGw" type="text/x-jquery-tmpl">
<div>
<select class='form-control' name='items[${index}].gwname' >
	<option value="投标制作人" {{if type==="投标制作人"}}selected{{/if}}>投标制作人</option>
    <option value="初审人" {{if type==="初审人"}}selected{{/if}}>初审人</option>
	<option value="复审人" {{if type==="复审人"}}selected{{/if}}>复审人</option>
	<option value="审定人" {{if type==="审定人"}}selected{{/if}}>审定人</option>
</select>
</div>
</script>